package com.weaver.openapi.service;

import com.weaver.openapi.pojo.mainline.params.*;
import com.weaver.openapi.pojo.mainline.res.*;
import com.weaver.openapi.util.*;
import java.util.*;
import cn.hutool.http.*;
import com.alibaba.fastjson.*;
import com.weaver.openapi.pojo.*;

public class MainlineService
{
    public static MainlineResultVo createMainlineV2(final MainlineVo mainlineVo, String host, final Map<String, String> headers) {
        host = HostUtil.beforeRequestCheckHeaders(host, headers, "application/x-www-form-urlencoded");
        final Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("access_token", mainlineVo.getAccessToken());
        paramMap.put("userid", mainlineVo.getUserid());
        paramMap.put("name", mainlineVo.getName());
        paramMap.put("description", mainlineVo.getDescription());
        paramMap.put("startTime", mainlineVo.getStartTime());
        paramMap.put("endTime", mainlineVo.getEndTime());
        paramMap.put("commonFormData", mainlineVo.getCommonFormData());
        paramMap.put("formId", mainlineVo.getFormId());
        paramMap.put("mainlineGroupFormData", mainlineVo.getMainlineGroupFormData());
        final String resJson = ((HttpRequest)HttpRequest.post(host + "/mainline/v2/create").form((Map)paramMap).headerMap((Map)headers, true)).execute().body();
        return (MainlineResultVo)JSONObject.parseObject(resJson, (Class)MainlineResultVo.class);
    }
    
    public static MessageResult deleteMainlineV2(final MainlineVo mainlineVo, String host, final Map<String, String> headers) {
        host = HostUtil.beforeRequestCheckHeaders(host, headers, "application/x-www-form-urlencoded");
        final Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("access_token", mainlineVo.getAccessToken());
        paramMap.put("userid", mainlineVo.getUserid());
        paramMap.put("id", mainlineVo.getId());
        final String resJson = ((HttpRequest)HttpRequest.post(host + "/mainline/v2/delete").form((Map)paramMap).headerMap((Map)headers, true)).execute().body();
        System.out.println(resJson);
        return (MessageResult)JSONObject.parseObject(resJson, (Class)MessageResult.class);
    }
    
    public static MessageResult updateMainlineV2(final MainlineVo mainlineVo, String host, final Map<String, String> headers) {
        host = HostUtil.beforeRequestCheckHeaders(host, headers, "application/x-www-form-urlencoded");
        final Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("access_token", mainlineVo.getAccessToken());
        paramMap.put("userid", mainlineVo.getUserid());
        paramMap.put("id", mainlineVo.getId());
        paramMap.put("propertyName", mainlineVo.getPropertyName());
        paramMap.put("propertyValue", mainlineVo.getPropertyValue());
        final String resJson = ((HttpRequest)HttpRequest.post(host + "/mainline/v2/update").form((Map)paramMap).headerMap((Map)headers, true)).execute().body();
        System.out.println(resJson);
        return (MessageResult)JSONObject.parseObject(resJson, (Class)MessageResult.class);
    }
    
    public static MainlineResultVo getMainlineInfoV2(final MainlineVo mainlineVo, String host, final Map<String, String> headers) {
        host = HostUtil.beforeRequestCheckHeaders(host, headers, "application/x-www-form-urlencoded");
        final Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("access_token", mainlineVo.getAccessToken());
        paramMap.put("id", mainlineVo.getId());
        final String resJson = ((HttpRequest)HttpRequest.get(host + "/mainline/v2/info").form((Map)paramMap).headerMap((Map)headers, true)).execute().body();
        System.out.println(resJson);
        return (MainlineResultVo)JSONObject.parseObject(resJson, (Class)MainlineResultVo.class);
    }
    
    public static MainlineResultVo queryMainlinesV2(final MainlineVo mainlineVo, String host, final Map<String, String> headers) {
        host = HostUtil.beforeRequestCheckHeaders(host, headers, "application/x-www-form-urlencoded");
        final Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("access_token", mainlineVo.getAccessToken());
        paramMap.put("beginDateStr", mainlineVo.getBeginDateStr());
        paramMap.put("endDateStr", mainlineVo.getEndDateStr());
        final String resJson = ((HttpRequest)HttpRequest.post(host + "/mainline/v2/queryMainlines").form((Map)paramMap).headerMap((Map)headers, true)).execute().body();
        System.out.println(resJson);
        return (MainlineResultVo)JSONObject.parseObject(resJson, (Class)MainlineResultVo.class);
    }
    
    public static MainlineResultVo queryMineInfoV2(final MainlineVo mainlineVo, String host, final Map<String, String> headers) {
        host = HostUtil.beforeRequestCheckHeaders(host, headers, "application/x-www-form-urlencoded");
        final Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("access_token", mainlineVo.getAccessToken());
        paramMap.put("userid", mainlineVo.getUserid());
        final String resJson = ((HttpRequest)HttpRequest.post(host + "/mainline/v2/mineInfo").form((Map)paramMap).headerMap((Map)headers, true)).execute().body();
        System.out.println(resJson);
        return (MainlineResultVo)JSONObject.parseObject(resJson, (Class)MainlineResultVo.class);
    }
    
    public static MainlineResultVo queryMainlineTasksV2(final MainlineVo mainlineVo, String host, final Map<String, String> headers) {
        host = HostUtil.beforeRequestCheckHeaders(host, headers, "application/x-www-form-urlencoded");
        final Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("access_token", mainlineVo.getAccessToken());
        paramMap.put("id", mainlineVo.getId());
        paramMap.put("containFinished", mainlineVo.isContainFinished());
        final String resJson = ((HttpRequest)HttpRequest.post(host + "/mainline/v2/queryMainlineTasks").form((Map)paramMap).headerMap((Map)headers, true)).execute().body();
        System.out.println(resJson);
        return (MainlineResultVo)JSONObject.parseObject(resJson, (Class)MainlineResultVo.class);
    }
    
    public static MainlineResultVo queryMainlineRelevancesV2(final MainlineVo mainlineVo, String host, final Map<String, String> headers) {
        host = HostUtil.beforeRequestCheckHeaders(host, headers, "application/x-www-form-urlencoded");
        final Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("access_token", mainlineVo.getAccessToken());
        paramMap.put("id", mainlineVo.getId());
        paramMap.put("linkModule", mainlineVo.getLinkModule());
        final String resJson = ((HttpRequest)HttpRequest.post(host + "/mainline/v2/queryMainlineRelevances").form((Map)paramMap).headerMap((Map)headers, true)).execute().body();
        System.out.println(resJson);
        return (MainlineResultVo)JSONObject.parseObject(resJson, (Class)MainlineResultVo.class);
    }
    
    public static MainlineResultVo queryMainlineCategoriesV2(final MainlineVo mainlineVo, String host, final Map<String, String> headers) {
        host = HostUtil.beforeRequestCheckHeaders(host, headers, "application/x-www-form-urlencoded");
        final String resJson = ((HttpRequest)HttpRequest.get(host + "/mainline/v2/queryMainlineCategories?access_token=" + mainlineVo.getAccessToken()).headerMap((Map)headers, true)).execute().body();
        System.out.println(resJson);
        return (MainlineResultVo)JSONObject.parseObject(resJson, (Class)MainlineResultVo.class);
    }
    
    public static MainlineResultVo queryFormInfoByMainlineGroupV2(final MainlineVo mainlineVo, String host, final Map<String, String> headers) {
        host = HostUtil.beforeRequestCheckHeaders(host, headers, "application/x-www-form-urlencoded");
        final Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("access_token", mainlineVo.getAccessToken());
        paramMap.put("groupId", mainlineVo.getGroupId());
        final String resJson = ((HttpRequest)HttpRequest.get(host + "/mainline/v2/queryFormInfoByMainlineGroup").form((Map)paramMap).headerMap((Map)headers, true)).execute().body();
        System.out.println(resJson);
        return (MainlineResultVo)JSONObject.parseObject(resJson, (Class)MainlineResultVo.class);
    }
    
    public static MainlineResultVo queryUpdateMainlinesV2(final MainlineVo mainlineVo, String host, final Map<String, String> headers) {
        host = HostUtil.beforeRequestCheckHeaders(host, headers, "application/x-www-form-urlencoded");
        final Map<String, Object> paramMap = new HashMap<String, Object>();
        paramMap.put("access_token", mainlineVo.getAccessToken());
        paramMap.put("startTime", mainlineVo.getStartTime());
        paramMap.put("endTime", mainlineVo.getEndTime());
        final String resJson = ((HttpRequest)HttpRequest.post(host + "/mainline/v2/queryUpdateMainlines").form((Map)paramMap).headerMap((Map)headers, true)).execute().body();
        System.out.println(resJson);
        return (MainlineResultVo)JSONObject.parseObject(resJson, (Class)MainlineResultVo.class);
    }
}
